package com.youan.serve.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youan.pangu.security.bean.LoginInfor;
import com.youan.serve.dao.domain.SyscodeDetail;
import com.youan.serve.service.ISyscodeDetailService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.constraints.NotNull;

/**
 * @description:
 * @author: 辛晟昊
 * @time: 2020/2/29 15:20
 */
@Controller
@Validated
@RequestMapping("/test")
public class TestController {
    @Autowired
    private ISyscodeDetailService syscodeDetailService;

    @GetMapping("/error1")
    public void error1(){
        int a = 1/0;
    }

    @GetMapping("/error2")
    public void error2() throws Exception {
        throw new Exception("不允许访问");
    }

    @GetMapping("/void")
    public void noret(){

    }

    @GetMapping("/string")
    public String getStr(){
        return "aaaa";
    }

    @GetMapping("/getInt")
    public int getInt(){
        return 1;
    }

    @GetMapping("/getPage")
    @ApiOperation("getAll")
    public void getAll(Page<SyscodeDetail> page){
        Page<SyscodeDetail> resut = syscodeDetailService.page(page);
    }

    @GetMapping("/validate1")
    public String validate(@NotNull String id){
        return id;
    }

    @GetMapping("/getLoginInfo")
    public String getLoginInfor(@ApiIgnore LoginInfor loginInfor){
        return loginInfor.getUsername();
    }

}
